Skip to content

Feat: nexchange plugin#212

Open
MMrj9 wants to merge 2 commits into
EdgeApp:masterfrom
MMrj9:feat/nexchange-plugin
Open

Feat: nexchange plugin#212
MMrj9 wants to merge 2 commits into
EdgeApp:masterfrom
MMrj9:feat/nexchange-plugin

Conversation

@MMrj9
Copy link
Copy Markdown

@MMrj9 MMrj9 commented Mar 2, 2026

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

Api Key should be shared privately

Description

  • Added new nexchange partner plugin at src/partners/nexchange.ts.
  • Integrated the plugin into the query engine in src/queryEngine.ts.
  • Implemented Edge audit orders API ingestion (/audits/edge/orders) with support for:
    • API key auth via x-api-key
    • Legacy Authorization: ApiKey <key> auth header
    • Cursor pagination with offset fallback
    • dateFrom incremental sync using persisted latestIsoDate and lookback
  • Added tests in test/nexchange.test.ts for transaction mapping and auth header behavior.

https://app.asana.com/1/9976422036640/project/1200382638405084/task/1213650284151456?focus=true


Note

Medium Risk
Changes how swap volume is priced when token resolution fails (ChangeNow/Rango may stop mid-sync until fixed), and new partner sync depends on catalog + audit APIs—incorrect mapping would affect reported USD volume.

Overview
Adds a new n.exchange swap partner that ingests Edge audit orders (/audits/edge/orders) with x-api-key auth, 5-day dateFrom lookback, and cursor/offset pagination, enriching orders via the v2 currency catalog into StandardTx (chain plugin id, token id, EVM chain id). Unknown networks/fiat stay unmapped; tokens with contracts throw instead of being treated as native so volume is not priced as the gas token.

ChangeNow and Rango adopt the same rule: failed createTokenId / asset resolution stops the run (no silent tokenId: null or per-tx skip). Rango also maps MONAD and SUI blockchains.

Wires nexchange into the query engine and demo partner list; adds test/nexchange.test.ts for mapping, dates, and asset resolution.

Reviewed by Cursor Bugbot for commit 130f101. Bugbot is set up for automated code reviews on this repo. Configure here.

@EdgeApp EdgeApp deleted a comment from cursor Bot Apr 2, 2026
@Jon-edge
Copy link
Copy Markdown

Jon-edge commented Apr 2, 2026

@cursor review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 2, 2026

Bugbot couldn't run

Bugbot is not enabled for your user on this team.

Ask your team administrator to increase your team's hard limit for Bugbot seats or add you to the allowlist in the Cursor dashboard.

@j0ntz j0ntz mentioned this pull request Apr 17, 2026
2 tasks
@paullinator paullinator force-pushed the feat/nexchange-plugin branch from 1adc15c to 4bd3686 Compare May 28, 2026 20:54
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 28, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@paullinator paullinator force-pushed the feat/nexchange-plugin branch from 4bd3686 to bd33954 Compare June 4, 2026 04:04
Comment thread src/partners/nexchange.ts
// iteration.
cursor = undefined
offset += orders.length
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor offset fallback undercounts

High Severity

In queryNexchange, offset is only increased in the branch where nextCursor is missing, while earlier pages may have been fetched with cursor and left offset at 0. If the API later falls back to offset-based paging, the request can skip hundreds of orders or repeat an earlier page.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bd33954. Configure here.

MMrj9 and others added 2 commits June 4, 2026 07:49
Co-authored-by: Cursor <cursoragent@cursor.com>
When an asset has a contract address it is a token, but several plugins
silently fell back to a native (tokenId: null) mapping when the token
could not be resolved. That prices the token with the chain's gas-token
rate and overcounts volume whenever the token is worth less than the gas
token.

- nexchange: throw when a contract-bearing asset is on a chain whose
  tokenType is missing, instead of returning tokenId: null.
- changenow: drop the try/catch around createTokenId that swallowed
  failures and returned tokenId: null.
- rango: drop the per-tx try/catch that logged and continued, silently
  dropping any transaction whose asset could not be resolved.

All three plugins paginate oldest-to-newest and persist progress on
throw, so a failing order halts and is retried next run rather than being
mispriced or silently dropped.

Also add the SUI and MONAD chain mappings to rango: these were
previously dropped silently and would now halt the plugin. Verified by
reprocessing the last three months of orders (nexchange 22.7k, changenow
61.9k, rango 2.9k) with zero processing failures.

Co-authored-by: Cursor <cursoragent@cursor.com>
@paullinator paullinator force-pushed the feat/nexchange-plugin branch from bd33954 to 130f101 Compare June 4, 2026 14:50
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 130f101. Configure here.

Comment thread src/partners/nexchange.ts
export function processNexchangeTx(
rawTx: unknown,
currencyMap: NexchangeCurrencyInfoMap
): StandardTx {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processNexchangeTx wrong signature

Medium Severity

processNexchangeTx takes (rawTx, currencyMap) instead of (rawTx, pluginParams). Planned backfill tooling invokes every process*Tx with only rawTx and pluginParams, so this handler cannot load the currency catalog on its own like other partner plugins.

Fix in Cursor Fix in Web

Triggered by learned rule: process*Tx must have uniform signature for backfill scripts

Reviewed by Cursor Bugbot for commit 130f101. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants